<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>

<html class="app-ui">

<head>
    <!-- Meta -->
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>

    <!-- Document title -->
    <title>我的评价</title>

    <meta name="description" content="AppUI - Admin Dashboard Template & UI Framework"/>
    <meta name="author" content="rustheme"/>
    <meta name="robots" content="noindex, nofollow"/>

    <!-- Favicons -->
    <link rel="apple-touch-icon" href="${pageContext.request.contextPath}/assets/img/favicons/apple-touch-icon.png"/>
    <link rel="icon" href="${pageContext.request.contextPath}/assets/img/favicons/favicon.ico"/>


    <!-- AppUI CSS stylesheets -->
    <link rel="stylesheet" id="css-font-awesome" href="${pageContext.request.contextPath}/assets/css/font-awesome.css"/>
    <link rel="stylesheet" id="css-ionicons" href="${pageContext.request.contextPath}/assets/css/ionicons.css"/>
    <link rel="stylesheet" id="css-bootstrap" href="${pageContext.request.contextPath}/assets/css/bootstrap.css"/>
    <link rel="stylesheet" id="css-app" href="${pageContext.request.contextPath}/assets/css/app.css"/>
    <link rel="stylesheet" id="css-app-custom" href="${pageContext.request.contextPath}/assets/css/app-custom.css"/>
    <!-- End Stylesheets -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/layui/css/layui.css" media="all">
</head>

<body class="app-ui layout-has-drawer layout-has-fixed-header">
<div class="app-layout-canvas">
    <div class="app-layout-container">

        <!-- Drawer -->
        <aside class="app-layout-drawer">

            <!-- Drawer scroll area -->
            <div class="app-layout-drawer-scroll" style="margin-top: 50px;">
                <!-- Drawer logo -->
                <div id="logo" class="drawer-header"
                     style="text-align: center;margin: 0 auto;font-family: 华文楷体; padding-top: 20px;">
                    <span style="font-size: 34px;"><strong>我的账户</strong></span>
                </div>

                <!-- Drawer navigation -->
                <nav class="drawer-main">
                    <ul class="nav nav-drawer">
                        <li class="nav-item nav-drawer-header">
                            <hr color="#ccc">
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/MyMoneyRecord.jsp"><i class="ion-ios-speedometer-outline"></i>
                                <span>我的账户流水</span></a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myInformation.jsp"><i class="ion-ios-monitor-outline"></i> 我的信息</a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myOrder.jsp"><i class="ion-ios-monitor-outline"></i> 我的订单</a>
                        </li>
                        <li class="nav-item">
                            <a href="${pageContext.request.contextPath}/jsp/MyAccount/myReceiveAddress.jsp"><i class="ion-ios-monitor-outline"></i> 我的收获地址</a>
                        </li>
                        <li class="nav-item">
                            <a href="javascript:void(0)"><i class="ion-ios-monitor-outline"></i> <span style="font-size: 20px;">我的评价</span></a>
                        </li>
                    </ul>
                </nav>
                <!-- End drawer navigation -->
            </div>
            <!-- End drawer scroll area -->
        </aside>
        <!-- End drawer -->

        <!-- Header -->
        <header class="app-layout-header">
            <nav class="navbar navbar-default">
                <div class="container">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                                data-target="#header-navbar-collapse"
                                aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <button class="pull-left hidden-lg hidden-md navbar-toggle" type="button" data-toggle="layout"
                                data-action="sidebar_toggle">
                            <span class="sr-only">Toggle drawer</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="${pageContext.request.contextPath}/jsp/home/frontend_home.jsp">
                            <img class="img-responsive"
                                 src="${pageContext.request.contextPath}/assets/img/logo/logo-frontend.png"
                                 title="强强组合商城" alt="AppUI"/>
                        </a>
                    </div>

                    <div class="collapse navbar-collapse" id="header-navbar-collapse">
                        <ul id="main-menu" class="nav navbar-nav navbar-left">
                            <li class="">
                                <a href="${pageContext.request.contextPath}/jsp/home/frontend_home.jsp">首页</a>
                            </li>
                            <li class="">
                                <a href="#" data-toggle="dropdown">关于我们</a>
                            </li>
                        </ul>
                        <!-- .navbar-left -->

                        <ul class="nav navbar-nav navbar-right navbar-toolbar hidden-sm hidden-xs">
                            <li class="active" id="business">
                                <a href="frontend_home.html">注册为商家</a>
                            </li>
                            <li class="active" id="deliver">
                                <a href="frontend_home.html">注册为配送员</a>
                            </li>
                            <li class="dropdown">
                                <a href="javascript:void(0)" data-toggle="dropdown"><i class="ion-ios-bell"></i> <span class="badge">3</span></a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li class="dropdown-header">消息</li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right">3</span> 有无内鬼？ </a>
                                    </li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right">1</span> 不过如此 </a>
                                    </li>
                                    <li class="divider"></li>
                                    <li class="dropdown-header">公告</li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)">登dua郎..</a>
                                    </li>
                                </ul>
                            </li>

                            <li class="dropdown dropdown-profile">
                                <a href="javascript:void(0)" data-toggle="dropdown">
                                    <span class="m-r-sm">${account.accName}<span class="caret"></span></span>
                                    <img class="img-avatar img-avatar-48" src="${pageContext.request.contextPath}/file/acc/${account.accImg == null?"000000011612245316757212.png":account.accImg}" alt="User profile pic" />
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li>
                                        <a href="${pageContext.request.contextPath}/jsp/MyAccount/MyMoneyRecord.jsp">个人账户</a>
                                    </li>
                                    <li>
                                        <a href="${pageContext.request.contextPath}/jsp/MyAccount/myBuyCart.jsp">我的购物车</a>
                                    </li>
                                    <li>
                                        <a href="#" id="logout">退出</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                        <!-- .navbar-right -->
                    </div>
                </div>
                <!-- .container-fluid -->
            </nav>
            <!-- .navbar-default -->
        </header>
        <!-- End header -->


        <main class="app-layout-content">

            <!-- Page Content -->
            <div class="container-fluid p-y-md">
                <div id="opiContent">
                </div>
                <div class="text-center">
                    <button class="btn btn-info" type="button" data-toggle="tooltip" title="首页" id="first"><i class="fa fa-angle-double-left"></i></button>&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-info" type="button" data-toggle="tooltip" title="上一页" id="left"><i class="fa fa-angle-left"></i></button>&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-info" type="button" data-toggle="tooltip" title="下一页" id="right"><i class="fa fa-angle-right"></i></button>&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-info" type="button" data-toggle="tooltip" title="尾页" id="last"><i class="fa fa-angle-double-right"></i></button>&nbsp;&nbsp;&nbsp;
                    总页数:<span id="allOpinionsPage"></span>&nbsp;&nbsp;当前为第<span id="pageCurrent"></span>页
                </div>
                <!-- .card -->
                <!-- End Page Content -->
            </div>

        </main>

    </div>
    <!-- .app-layout-container -->
</div>

<!-- .app-layout-canvas -->

<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.scrollLock.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.placeholder.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/app-custom.js"></script>

<!-- Page JS Plugins -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/masked-inputs/jquery.maskedinput.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/dropzonejs/dropzone.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/jquery-tags-input/jquery.tagsinput.min.js"></script>
<div class="app-ui-mask-modal"></div>

<script src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<script src="${pageContext.request.contextPath}/js/layui/layui.js"></script>

<script type="text/javascript">
    $(function (){
        var accId = ${account.accId};
        var page = 1;//当前显示的页数
        $("#pageCurrent").html(page);
        var limit = 2;//每页显示的数据笔数
        var goodsCount=0;//数据笔数
        var allOpinionsPage = 0;//总页数
        getMyOpinionContent();//获取评价内容

        function getMyOpinionContent() {
            var url = "${pageContext.request.contextPath}/accountInfo/selectMyOpinion";
            var param = {
                accId:accId,
                page:page,
                limit:limit
            };
            $.get(url,param,function (data) {
                if (data.code == 1001){
                    goodsCount = data.opinionsNum;
                    /*设置数据总笔数*/
                    allOpinionsPage = parseInt((goodsCount+1)/limit);
                    $("#allOpinionsPage").html(allOpinionsPage);
                    $("#opiContent").html("");
                    var content = "";
                    for (var i = 0; i < data.opinions.length; i++) {
                        content += "<div class='card'><div class='card-header row col-md-12'><div class='col-md-2'>";
                        content += "<img class='img-responsive' src='${pageContext.request.contextPath}/file/goodsInfo/"+data.opinions[i].goods.imgUrl+"' style='width: 130px;height: 100px;' alt='User profile pic' />";
                        content += "</div><div class='col-md-5'><p class='font-500 m-b-0'>"+data.opinions[i].goods.goNm+"</p><p class='hidden-xs'>"+data.opinions[i].goods.goDp+"</p>";
                        content += "</div><div class='col-md-5' style='left: 200px;'>";
                        content += "<button class='btn btn-app-orange deleteOpinion' style='width: 100px;height: 60px;' type='button' title='不想看见它' value='"+data.opinions[i].opinion.opiId+"'><span>删除</span></button>";
                        content += "</div></div><div class='card-block'><table class='js-table-checkable table table-vcenter table-hover'> <tr><td class='text-center'><td><h3 class='h5 m-b-xs'>";
                        content += "<span>我的评价</span></h3><p>";
                        if (data.opinions[i].opinion.opiType == 1){
                            content += "<span class='label label-success'><i class='fa fa-smile-o'></i> 好评</span>";
                        }else if (data.opinions[i].opinion.opiType == 2){
                            content += "<span class='label label-success'><i class='fa fa-meh-o'></i> 中评</span>";
                        }else {
                            content += "<span class='label label-success'><i class='fa fa-frown-o'></i> 差评</span>";
                        }
                        content += "</p><div class='font-s23 text-muted hidden-xs'>";
                        content += "<p style='font-size: 20px;font-family: 华文楷体;'>&nbsp;&nbsp;&nbsp;&nbsp;<span>"+data.opinions[i].opinion.opiContent+"</span></p>";
                        content += "<div class='row'>";
                        for (var j = 0; j < data.opinions[i].opinion.opinionFile.length; j++) {
                                if (j%2 == 0 && j != 0){
                                    content += "</div><div class='row'>";
                                }
                            content += "<div class='col-lg-2'><div class='card'><img class='img-responsive' src='${pageContext.request.contextPath}/file/opinionFile/"+data.opinions[i].opinion.opinionFile[j]+"' style='width: 230px;height: 100px;'/></div></div>"
                            }

                        content += "</div><p class='pull-right hidden-sm hidden-xs'>"+data.opinions[i].opinion.opiTime+"</p>";
                        content += "</div></td></td></tr></table></div></div>";
                    }
                    $("#opiContent").html(content);
                }
            });
        }
        /*  删除评价    */
        $("#opiContent").delegate(".deleteOpinion","click",function () {
            var opiId = $(this).val();
            var url = "${pageContext.request.contextPath}/accountInfo/deleteMyOpinion";
            var param = {
                opiId:opiId,
                _method:"delete"
            }
            $.post(url,param,function (data) {
                if (data.code == 1001){
                    alert("删除成功！");
                    getMyOpinionContent();
                }
            });
        });

        /* 分页按钮--start */
        $("#right").click(function () {
            if (allOpinionsPage < page+1){
                return false;
            }
            page += 1;
            $("#pageCurrent").html(page)
            getMyOpinionContent();
        });
        $("#left").click(function () {
            if (page-1 < 1){
                return false;
            }
            page -= 1;
            $("#pageCurrent").html(page)
            getMyOpinionContent();

        });
        $("#first").click(function () {
            if (page == 1){
                return false;
            }
            page = 1;
            $("#pageCurrent").html(page)
            getMyOpinionContent();
        });
        $("#last").click(function () {
            if (page == allOpinionsPage){
                return false;
            }
            page = allOpinionsPage;
            $("#pageCurrent").html(page)
            getMyOpinionContent();
        });
        /* 分页按钮--end */


        /*动态显示首页头部*/
        var role = ${account.role};
        if(role == 2){
            $("#business").html("<a href='../business/UnFinishOrder.jsp'>商家后台</a>");
            $("#deliver").html("");
        }
        if(role == 3){
            $("#business").html("");
            $("#deliver").html("<a href='#'>配送员后台</a>");
        }
        /*退出登录*/
        $("#logout").click(function (event){
            event.preventDefault();
            var url = "/login/logoutShop";
            $.post(url,function (){
                window.location.href = "../../login.jsp";
            })
        })


    });

</script>

</body>

</html>
